package com.tiancheng.trade.settlement.controller.admin;

import com.tiancheng.trade.commom.core.data.Result;
import com.tiancheng.trade.settlement.service.settlement.ISSettleLettersService;
import com.tiancheng.trade.settlement.vo.settlement.admin.SSettleLettersDetailQueryVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import jakarta.validation.Valid;
import java.util.List;

/**
 * 对账函
 *
 * @author likailun
 */
@RestController
@RequestMapping("/admin/settleLetters")
@Validated
@Slf4j
public class SSettleLettersAdminController {
    @Resource
    private ISSettleLettersService settleLettersService;

    @PostMapping
    public Result queryLit(@Valid @RequestBody SSettleLettersDetailQueryVo SSettleLettersDetailQueryVo){
        return Result.success(settleLettersService.queryLit(SSettleLettersDetailQueryVo));
    }

    @PostMapping("/generate")
    public Result generateSettleLetters(@Valid @RequestBody SSettleLettersDetailQueryVo SSettleLettersDetailQueryVo){
        return settleLettersService.generateSettleLetters(SSettleLettersDetailQueryVo);
    }

    @PostMapping("/deleteBySettleLettersCode")
    public Result deleteBySettleLettersCode(@RequestBody List<String> cods){
        settleLettersService.deleteBySettleLettersCode(cods);
        return Result.success("删除对账函成功！");
    }

    /**
     * 判断是否有任务在运行
     *
     * @return
     */
    @GetMapping(value = "/isExistGenerateTask")
    public Result<Boolean> isExistGenerateTask() {
        return Result.success(settleLettersService.isExistGenerateTask());
    }

}
